<!DOCTYPE html>
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	    <meta name="format-detection" content="telephone=no">
	    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
	    <link href="../../../css/bootstrap.css" rel="stylesheet" />
	    <link href="../../../css/cover.css" rel="stylesheet" />
	    <link href="../../../css/font-awesome.min.css" rel="stylesheet" />
	    <title>荆州千网汇信息科技有限公司</title>
	    <script src="../../../js/jquery-2.2.3.min.js"></script>
	    <script src="../../../js/jquery.flexslider-min.js"></script>
	    <script src="../../../js/rem.js"></script>
	    <script src="../../../js/itnetcao.js"></script>
	    
	    <link href="../../../js/layui/css/layui.css" rel="stylesheet" />
	    
	    <link href="../../../js/donghua/animsition.min.css" rel="stylesheet" />
	    <script src="../../../js/donghua/animsition.min.js"></script>
	    <link rel="stylesheet" href="../../../css/minirefresh.css" />
	    <link rel="stylesheet" href="../../../css/common.css" />
	    <script type="text/javascript" src="../../../js/minirefresh.js"></script>
	    <script type="text/javascript" src="../../../js/common.js"></script>
		
	</head>
	<body style='width:100%;'>
		
		
		<div class="page_top01 relative">
            <h3 class="text-center">实名认证</h3>
            <a href="javascript:;" class="animsition-link" data-animsition-out-class="fade-out-right" data-animsition-out-duration="500" onclick="history.go(-1)">
                <img src="../../../images/icon_left.png" class="img-responsive reture_img" /></a>

        </div>
		
		
		<div class="layui-fluid layui-form layui-form-pane" style='margin-top:10%;'>
			
			<input type="hidden" name="authIdId">
			<input type="hidden" name="authExamine">
			
			<input type="hidden" name="authIdentityCardZheng">
			<input type="hidden" name="authIdentityCardFan">
			
			<div class="layui-row layui-col-space15">
				<div class="layui-col-xs12">
					<div class="layui-form-item">
					    <label class="layui-form-label">姓名</label>
					    <div class="layui-input-block">
							<input type="text" name="authIdName" placeholder="请输入名称" class="layui-input">
					    </div>
					</div>
				</div>
			</div>
			
			<div class="layui-row layui-col-space15">
				<div class="layui-col-xs12">
					<div class="layui-form-item">
					    <label class="layui-form-label">身份证</label>
					    <div class="layui-input-block">
							<input type="text" name="authIdIdentity" placeholder="请输入身份证信息" class="layui-input">
					    </div>
					</div>
				</div>
			</div>
			
			<div class="layui-row layui-col-space15">
				<div class="layui-col-xs12">
					<div class="layui-form-item">
					    <label class="layui-form-label">银行卡</label>
					    <div class="layui-input-block">
							<input type="text" name="authBankCard" placeholder="请输入银行卡信息" class="layui-input">
					    </div>
					</div>
				</div>
			</div>
			
			<div class="layui-row layui-col-space15">
				<div class="layui-col-xs12">
					<div class="layui-form-item">
					    <label class="layui-form-label">手机号</label>
					    <div class="layui-input-block">
							<input type="text" name="authBankCardIphone" placeholder="请输入银行卡预留手机号码" class="layui-input">
					    </div>
					</div>
				</div>
			</div>
			
			<div class="layui-row layui-col-space15">
				<div class="layui-col-xs12">
					<div class="layui-form-item">
					    <label class="layui-form-label">身份证照片</label>
					    <div class="layui-input-block">	
					    	<button onclick="document.getElementById('FacadeIDCard').click();" class="layui-btn layui-btn-warm" style='width:100%;'>正面上传</button>
					    	<input type='file' id="FacadeIDCard" name="authIdentityCardZheng" style='display:none;'/>
					    </div>
					</div>
				</div>
			</div>
			
			<div class="layui-row layui-col-space15">
				<div class="layui-col-xs12" align="center">
					<img class='authIdentityCardZhengYuLan' style='width:100px;height:100px;'/>
				</div>
			</div>
			
			<div class="layui-row layui-col-space15">
				<div class="layui-col-xs12">
					<div class="layui-form-item">
					    <label class="layui-form-label">身份证照片</label>
					    <div class="layui-input-block">	
					    	<button onclick="document.getElementById('identityCard').click();" class="layui-btn layui-btn-warm" style='width:100%;'>反面上传</button>
					    	<input type='file' id="identityCard" name="authIdentityCardFan" style='display:none;'/>
					    </div>
					</div>
				</div>
			</div>
			
			<div class="layui-row layui-col-space15">
				<div class="layui-col-xs12" align="center">
					<img class='authIdentityCardFanYuLan' style='width:100px;height:100px;'/>
				</div>
			</div>
			
			<div class="layui-row layui-col-space15">
				<div class="layui-col-xs12">
					<p>注:姓名、身份证、银行卡号、预留手机号必须保存一致，系统自动检测，如不一致，将无法通过认证。XTS团队重视保障用户的个人信息，用户的个人信息将被严格保密。</p>
					<p>此实名认证系统仅限于XTS团队认证身份证信息，保证不对外公开或向第三方提供用户个人信息。</p>
				</div>
			</div>
			
			<div class="layui-row layui-col-space15">
				<div class="layui-col-xs12">
					<button class="layui-btn layui-btn-warm saveOrUpdate" style='width:100%;'>保存</button>
				</div>
			</div>
			
		</div>
		
<script type='text/javascript'>
var userId = jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userId;
var updateHtml = "";
// 获取用户实名认证信息
var url_1 = localStorage.getItem("url") + "/user/controller/UserFindIdentityAuthenticationAPP.do";
var data_1 = "userId=" + userId;
itcao.itGetAjaxBigData(url_1, data_1).done(function(result) {
	var json = jQuery.parseJSON(result);
	if(json.state == true) {
		if(json.bean.authExamine == 0) {
			
			$(".saveOrUpdate").text("修改");
			$("input[name='authIdName']").val(json.bean.authIdName);
			$("input[name='authIdIdentity']").val(json.bean.authIdIdentity);
			$("input[name='authBankCard']").val(json.bean.authBankCard);
			$("input[name='authBankCardIphone']").val(json.bean.authBankCardIphone);
			$("input[name='authIdId']").val(json.bean.authIdId);
			$("input[name='authExamine']").val(json.bean.authExamine);
			$("input[name='authIdentityCardZheng']")[0].value = json.bean.authIdentityCardZheng;
			$("input[name='authIdentityCardFan']")[0].value = json.bean.authIdentityCardFan;
			
			$(".authIdentityCardZhengYuLan").attr("src", localStorage.getItem("url") + "/" + json.bean.authIdentityCardZheng);
			$(".authIdentityCardFanYuLan").attr("src", localStorage.getItem("url") + "/" + json.bean.authIdentityCardFan);
		}else {
		
			$("input[name='authIdName']").val(json.bean.authIdName);
			$("input[name='authIdIdentity']").val(json.bean.authIdIdentity);
			$("input[name='authBankCard']").val(json.bean.authBankCard);
			$("input[name='authBankCardIphone']").val(json.bean.authBankCardIphone);
			$("input[name='authIdId']").val(json.bean.authIdId);
			$("input[name='authExamine']").val(json.bean.authExamine);
			$("input[name='authIdentityCardZheng']")[0].value = json.bean.authIdentityCardZheng;
			$("input[name='authIdentityCardFan']")[0].value = json.bean.authIdentityCardFan;
			
			$(".authIdentityCardZhengYuLan").attr("src", localStorage.getItem("url") + "/" + json.bean.authIdentityCardZheng);
			$(".authIdentityCardFanYuLan").attr("src", localStorage.getItem("url") + "/" + json.bean.authIdentityCardFan);
			
			updateHtml = $(".layui-form").html();
			$(".layui-form").empty();
			
			$(".layui-form").append("<div class='layui-row layui-col-space15'><div class='layui-form-item'><label class='layui-form-label'>名称:</label><div class='layui-input-block'><input type='text' class='layui-input' disabled value='"+json.bean.authIdName+"'/></div></div></div>");
			$(".layui-form").append("<div class='layui-row layui-col-space15'><div class='layui-form-item'><label class='layui-form-label'>身份证:</label><div class='layui-input-block'><input type='text' class='layui-input' disabled value='"+json.bean.authIdIdentity+"'/></div></div></div>");
			$(".layui-form").append("<div class='layui-row layui-col-space15'><div class='layui-form-item'><label class='layui-form-label'>银行卡信息:</label><div class='layui-input-block'><input type='text' class='layui-input' disabled value='"+json.bean.authBankCard+"'/></div></div></div>");
			$(".layui-form").append("<div class='layui-row layui-col-space15'><div class='layui-form-item'><label class='layui-form-label'>预留手机号:</label><div class='layui-input-block'><input type='text' class='layui-input' disabled value='"+json.bean.authBankCardIphone+"'/></div></div></div>");
			$(".layui-form").append("<div class='layui-row layui-col-space15'><div class='layui-form-item'><label class='layui-form-label'>是否通过:</label><div class='layui-input-block'><input type='text' class='layui-input' disabled value='已认证'/></div></div></div>");
			
			//$(".layui-form").append("<div class='layui-row layui-col-space15' style='margin-top:2rem;'><button class='layui-btn layui-btn-warm update' style='width:100%;'>修改</button></div>");
		}
	}
})

function updateOrSave(url, idUpdate) {
	if($("input[name='authIdName']").val().trim().length == 0) {
		alert("您必须输入您的姓名.");
		return;
	}
	if($("input[name='authIdIdentity']").val().trim().length == 0) {
		alert("您必须输入您的身份证.");
		return;
	}
	if($("input[name='authBankCard']").val().trim().length == 0) {
		alert("您必须输入您的银行卡信息.");
		return;
	}
	if($("input[name='authBankCardIphone']").val().trim().length == 0) {
		alert("您必须输入您的银行卡手机预留号码.");
		return;
	}
	
	
	if($("#FacadeIDCard").val().trim().length != 0 && $("#identityCard").val().trim().length != 0) {
		var formData = new FormData();
		// 需要上传图片
		if(idUpdate) {
			formData.append("authIdId", $("input[name='authIdId']").val());
			formData.append("authExamine", $("input[name='authExamine']").val());
		}
		formData.append("authIdName", $("input[name='authIdName']").val());
		formData.append("authIdIdentity", $("input[name='authIdIdentity']").val());
		formData.append("authBankCard", $("input[name='authBankCard']").val());
		formData.append("authBankCardIphone", $("input[name='authBankCardIphone']").val());
		formData.append("authUserId", userId);
		if($('#FacadeIDCard').val().length == 0) {
			alert("您必须上传身份证正面图片");
			return;
		}
		if($('#identityCard').val().length == 0) {
			alert("您必须上传身份证反面图片");
			return;
		}
		
		formData.append('file', $('#FacadeIDCard')[0].files[0]);
		formData.append('file', $('#identityCard')[0].files[0]);
				
		itcao.itcaoGetImageAjaxData(url, formData).done(function(result) {
			var json = jQuery.parseJSON(result);
			if(json.state == true){
				alert("操作成功.");
				setTimeout(function() {
					window.location.href = "../userMineMain.html";
				}, 500)
			}else {
				alert("操作失败:" + json.value);
			}
		})
	}else {
		// 不需要上传图片
		
		var data = "&authIdName=" + $("input[name='authIdName']").val() + "&authIdIdentity=" + $("input[name='authIdIdentity']").val()
		+ "&authBankCard=" + $("input[name='authBankCard']").val() + "&authBankCardIphone=" + $("input[name='authBankCardIphone']").val()
		+ "&authUserId=" + userId + "&authIdentityCardZheng=" + $("input[name='authIdentityCardZheng']").val()
	 	+ "&authIdentityCardFan=" + $("input[name='authIdentityCardFan']").val();
		
		if(idUpdate) {
			data = data + "&authIdId=" + $("input[name='authIdId']").val();
			data = data + "&authExamine=" + $("input[name='authExamine']").val();
		}
		
		itcao.itGetAjaxTrueBigData(url, data).done(function(result) {
			var json = jQuery.parseJSON(result);
			if(json.state == true){
				alert("操作成功.");
				setTimeout(function() {
					window.location.href = "../userMineMain.html";
				}, 500)
			}else {
				alert("操作失败:" + json.value);
			}
		})
	}
	
}

$(function() {

	$(".update").click(function() {
		$(".layui-form").empty();
		$(".layui-form").html(updateHtml);
		$(".layui-form").append("<div class='layui-row layui-col-space15' style='margin-top:50px;'><button class='layui-btn layui-btn-warm updateGo' style='width:100%;'>修改</button></div>");
	})
	
	$(".updateGo").click(function() {
		
		var url = localStorage.getItem("url") + "/user/controller/UserIdentityUpdateAuthenticationAPP.do";
		
		updateOrSave(url, true);
	})
	
	$("#FacadeIDCard").change(function() {
		try{
			$(".authIdentityCardZhengYuLan").attr("src", window.URL.createObjectURL($("#FacadeIDCard").get(0).files.item(0)));
		}catch(e){}
	})
	
	$("#identityCard").change(function() {
		try{
			$(".authIdentityCardFanYuLan").attr("src", window.URL.createObjectURL($("#identityCard").get(0).files.item(0)));
		}catch(e){}
	})
	
	$(".saveOrUpdate").click(function() {
		
		if($(".saveOrUpdate").text() == "修改") {
			updateOrSave(localStorage.getItem("url") + "/user/controller/UserIdentityUpdateAuthenticationAPP.do", true);
		}else {
			updateOrSave(localStorage.getItem("url") + "/user/controller/UserIdentityAuthenticationAPP.do", false);
		}
		
	})
})

</script>
	</body>
</html>
